<?php

Raise::load('core.RaiseObject');

/**
 * RaiseStackFrame class
 * represents a single stack trace frane
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package phpraise.core.helper.trace
 * @since 1.2
 */
class RaiseStackFrame extends RaiseObject {

    /**
     * Defines a function call
     */
    const TYPE_FUNCTION = '';

    /**
     * Defines a static method call
     */
    const TYPE_STATIC = '::';

    /**
     * Defines a normal method call
     */
    const TYPE_METHOD = '->';

    /**
     * The identifier (function / method) name
     * @var string
     */
    private $name;

    /**
     * The line number of this stack frame
     * @var integer
     */
    private $line;

    /**
     * The path name to the stack frame
     * @var string
     */
    private $file;

    /**
     * The class name of the method.
     * @var string
     */
    private $className;

    /**
     * The object
     * @var mixed
     */
    private $object;

    /**
     * The type of call that this frame is, TYPE_FUNCTION, TYPE_STATIC, TYPE_METHOD
     * @var string
     */
    private $type;

    /**
     * The arguments passed to this stack frame
     * @var RaiseCollection
     */
    private $args;

    public function __construct(){
        $this->args = new RaiseCollection();
    }

    /**
     * Get or set the identifier (function / method) name
     * @param string $n (optional) Set the identifier (function / method) name
     * @return string
     */
    public function name($n = null){
        if(func_num_args() == 1){
            $this->name = $n;
        }
        return $this->name;
    }

    /**
     * Get or set the line number of the stack frame
     * @param integer $l (optional) Set the line number
     * @return integer
     */
    public function line($l = null){
        if(func_num_args() == 1){
            $this->line = $l;
        }
        return $this->line;
    }

    /**
     * Get or set the pathname to the file of the stack frame
     * @param string $f (optional) Set the pathname to the file of the stack frame
     * @return string
     */
    public function file($f = null){
        if(func_num_args() == 1){
            $this->file = $f;
        }
        return $this->file;
    }

    /**
     * Get or set the class name of the stack frame
     * @param string $c (optional) Set the class name
     * @return string
     */
    public function className($c = null){
        if(func_num_args() == 1){
            $this->className = $c;
        }
        return $this->className;
    }

    /**
     * Get or set the object of the stack frame
     * @param mixed $o (optional) Set the object of the stack frame
     * @return mixed
     */
    public function object($o = null){
        if(func_num_args() == 1){
            $this->object = $o;
        }
        return $this->object;
    }

    /**
     * Get or set the stack frame call type
     * @param string $t (optional) Set the stack frame call type
     * @return string
     */
    public function type($t = null){
        if(func_num_args() == 1){
            $this->type = $t;
        }
        return $this->type;
    }

    /**
     * Get the collection of arguments in the stack frame
     * @return Raisecollection
     */
    public function args(){
        return $this->args;
    }
}